import { Controller, Get, Header, Session } from '@nestjs/common';
import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
import { CaptchaService } from './captcha.service';

@ApiTags('Auth')
@Controller('captcha')
export class CaptchaController {
  constructor(private readonly captchaService: CaptchaService) { }

  @Get('captcha')
  @ApiOperation({ summary: '获取验证码图片' })
  // @ApiResponse({
  //   status: 200,
  //   description: '返回验证码图片',
  //   content: {
  //     'image/svg+xml': {
  //       schema: {
  //         type: 'string',
  //         format: 'binary',
  //       },
  //     },
  //   },
  // })
  // @Header('Content-Type', 'image/svg+xml') // 设置响应头为 SVG 图片
  getCaptchaImage(@Session() session) {
    const sessionId = session.id; // 获取会话ID
    return this.captchaService.generateCaptcha(sessionId);
  }
}